/*
 * @(#)FormData.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.form.bean;

import java.sql.Timestamp;

import com.dcivision.framework.bean.AbstractBaseObject;

/**
  FormData.java

  This class is the serializable bean reflecting business logic uses.

    @author           Scott Tong
    @company          DCIVision Limited
    @creation date    07/01/2004
    @version          $Revision: 1.9 $
*/

public class FormData extends AbstractBaseObject {

  public static final String REVISION = "$Revision: 1.9 $";

  static final long serialVersionUID = 875310019568395697L;

  private Integer dataElementID = null;
  private String dataString = null;
  private Float dataNumeric = null;
  private Timestamp dataDatetime = null;
  
  //audit trail
  private Integer sectionID = null;
  private String sectionName = null;
  private String elementName = null;
  private String preDataString = null;
  
  private Object dataObject = null;

  public FormData() {
    super();
  }

  public FormData(Integer dataElementID, Object dataObject) {
    super();
    this.dataElementID = dataElementID;
    this.dataObject = dataObject;
  }

  public Object getDataObject() {
    if(dataString!=null) return dataString;
    if(dataNumeric!=null) return dataNumeric;
    if(dataDatetime!=null) return dataDatetime;
    if(dataObject!=null) return dataObject;
    return null;
  }

  public void setDataObject(Object formData) {
    this.dataObject = formData;
  }

  public Integer getDataElementID() {
    return(this.dataElementID);
  }

  public void setDataElementID(Integer dataElementID) {
    this.dataElementID = dataElementID;
  }

  public String getDataString() {
    return(this.dataString);
  }

  public void setDataString(String dataString) {
    this.dataString = dataString;
    if(dataString!=null) setDataObject(dataString);
  }

  public Float getDataNumeric() {
    if(getDataObject() instanceof Number){
      return new Float(getDataObject().toString());
    }
    return null;
  }

  public void setDataNumeric(Float dataNumeric) {
    this.dataNumeric = dataNumeric;
    if(dataNumeric!=null) setDataObject(dataNumeric);
  }

  public Timestamp getDataDatetime() {
    return(this.dataDatetime);
  }

  public void setDataDatetime(Timestamp dataDatetime) {
    this.dataDatetime = dataDatetime;
    if(dataDatetime!=null) setDataObject(dataDatetime);
  }

  
  public Integer getSectionID() {
	return sectionID;
  }
	
  public void setSectionID(Integer sectionID) {
	this.sectionID = sectionID;
  }
	
  public String getSectionName() {
	return sectionName;
  }
	
  public void setSectionName(String sectionName) {
	this.sectionName = sectionName;
  }

  public String getElementName() {
	return elementName;
  }
	
  public void setElementName(String elementName) {
	this.elementName = elementName;
  }
  
  public String getPreDataString() {
	return preDataString;
  }
	
  public void setPreDataString(String preDataString) {
	this.preDataString = preDataString;
  }

   public boolean equalsData(Object obj) {
    return(obj != null && obj.getClass().getName().equals(this.getClass().getName()) && ((FormData)obj).getDataString() != null && ((FormData)obj).getDataString().equals(this.getDataString()));
  }

}
